//
//  CarCell.m
//  UI_Homework_12
//
//  Created by 黄威 on 16/5/18.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "CarCell.h"
#import "ModelOfCar.h"
@interface CarCell ()

@property (nonatomic,retain)UILabel *labelOftitle;
@property (nonatomic,retain)UILabel *laberOfcontect;
@property (nonatomic,retain)UIImageView *image;

@end
@implementation CarCell

-(void)dealloc{

    [_image release];
    [_labelOftitle release];
    [_laberOfcontect release];
    [super dealloc];

}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }

    return self;

}

//子控件布局

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.labelOftitle.frame =   CGRectMake(100, 10, 290, 40);
    self.laberOfcontect.frame = CGRectMake(100, 60, 290, 40);
    self.image.frame =CGRectMake(10, 10, 80, 70);


}

- (void)setModel:(ModelOfCar *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }

    self.labelOftitle.text = model.title;
    self.laberOfcontect.text = model.neirong;
    self.image.image = [UIImage imageNamed:model.image];

}

- (void)createSubviews{

    self.image = [[UIImageView alloc]init];
    [self.contentView addSubview:self.image];
    [_image release];
    self.image.backgroundColor = [UIColor redColor];
    
    
    self.labelOftitle = [[UILabel alloc]init];
    self.laberOfcontect = [[UILabel alloc]init];
    
    [self.contentView addSubview:_laberOfcontect];
    [self.contentView addSubview:_labelOftitle];
    
    self.laberOfcontect.backgroundColor = [UIColor greenColor];
    self.labelOftitle.backgroundColor = [UIColor yellowColor];
    
    
    



}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

















































